import java.util.*;


  class HouseService    {
      private House[] houses;
      private int count;

      public HouseService() {
          houses = new House[100];
          count = 0;
      }
    //添加

    public void addHouse(House house) {
        houses[count++] = house;
    }

    //查找

    public  House FinHouseName(String name){
        for (int i = 0; i < count; i++) {
            if (houses[i].getName().equals(name)) {
                return houses[i];
            }
        }
        return null;
    }
    //修改

    public void updateHouse(String name,String phone, String address, double price, String status) {
        House house = FinHouseName(name);
        if (house!= null) {
            house.setPhone(phone);
            house.setAddress(address);
            house.setPrice(price);
            house.setStatus(status);
        }
    }


    public void deleteHouse(String name) {
        for (int i = 0; i < count; i++) {
            if (houses[i].getName().equals(name)) {
                for (int j = i; j < count - 1; j++) {
                    houses[j] = houses[j + 1];
                }
                count--;
                break;
            }
        }
    }

    //打印明细表

    public  void printHouseList(){
        System.out.println("房屋明细表");
        System.out.println("名称 \t 电话 \t 地址 \t 月租 \t 状态");
            for (int i = 0; i < count; i++) {
                House house = houses[i];
                System.out.println(house.getName() + "\t" + house.getPhone() + "\t" + house.getAddress()
                        + "\t" + house.getPrice() + "\t" + house.getStatus());
            }
            }



}
